from encodings.utf_8 import encode
from idlelib.iomenu import encoding
from multiprocessing.context import Process

from Tools.scripts.generate_opcode_h import header
from numpy.lib.format import open_memmap
from requests import Request

import config
import requests
import time

# header = {
#     "User-Agent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36"
# }
# res = requests.get("http://www.baidu.com",headers=header)
# res.encoding = 'utf-8'
# print(f'请求头：{res.request.headers}')
# print(res.content.decode("utf-8"))
# print(res.__module__)
# print(res.__class__)
#---------------------------------------------------------

#多线程
# import threading
#
# def sing(name):
#     print(f"{name}在唱歌")
#     time.sleep(2)
#     print("歌唱完了")
#
# def dance(name):
#     print(f"{name}在跳舞")
#     time.sleep(2)
#     print("舞跳完了")
# # 设置子线程
# sing1 = threading.Thread(target=sing,args=("寂寞",))
# dance1 = threading.Thread(target=dance,args=("祭祀",))
# #设置线程名
# sing1.setName("子线程-1")
# dance1.setName("子线程-2")
# #获取线程名
# print(sing1.getName())
# print(dance1.getName())
# #守护线程，与主进程同时结束
# sing1.setDaemon(True)
# dance1.setDaemon(True)
# #开启线程
# sing1.start()
# dance1.start()
# #阻塞主线程
# sing1.join()
# dance1.join()
# #主线程
# print("表演结束")
#-------------------------------------------------------

#进程
# from multiprocessing import Process
# import os
#
# def sing():
#     print("唱歌")
#
# def dance():
#     print("跳舞")
#
# if __name__ == "__main__":
#     #创建子进程
#     p1 = Process(target=sing,name="子进程-1")
#     p2 = Process(target=dance,name="子进程-2")
#     #查看子进程名
#     print(p1.name)
#     print(p2.name)
#     #开启子进程
#     p1.start()
#     p2.start()
#     #查看进程编号
#     print(p1.pid)
#     print(p2.pid)
#     print(f'主进程id：{os.getpid()}')
#     print(f'主进程父id：{os.getppid()}')
#-----------------------------------------------

#协程--手动切换
# from greenlet import greenlet
#
# def sing():
#     print("在唱歌")
#     d1.switch()
#     print("唱完歌了")
#
# def dance():
#     print("在跳舞")
#     print("跳完舞了")
#
# if __name__ == "__main__":
#     g1 = greenlet(sing)
#     d1 = greenlet(dance)
#     g1.switch()
#     d1.switch()
#-----------------------------------------

#时间函数
# import time
# print(time.time()) #时间戳
# # print(time.localtime())  #当前时区的时间
# print(time.asctime())   #获取系统时间
# print(type(time.asctime()))
# t = time.strftime("%Y-%m-%d %H:%M:%S",time.localtime())
# print(t)
#-------------------------

#日志
import logging

# log_path = config.BASE_DIR + "/data/log.log"  # 设置日志文件的路径

# 设置日志的基本配置
# logging.basicConfig(
#     filename=log_path,  # 日志文件路径
#     level=logging.WARNING,  # 日志级别
#     format="%(asctime)s - %(levelname)s - %(message)s",  # 设置日志输出格式，包含时间、日志级别和消息
# )
#
# # 格式化日志信息
# message = "示例警告信息"
# logging.warning("警告日志: %s", message)
#------------------------------------------------------

#随机函数
# import random
#
# print(random.random())
# print(random.randint(1, 5))
# print(random.randrange(1, 999,step=1))
# print(random.uniform(1,4))
#----------------------------------------

#保存网页图片
# import requests
#
# pong = "https://public-oss.estudy.cn/php-resource/php-resource/1829176a92b1214/1def4cbc-012c-4e5b-989f-256830080d8c_2771.png"
# res = requests.get(pong)
# file = config.BASE_DIR + "/data/pong1.gif"
# with open(file,'wb') as f:
#     f.write(res.content)
#-----------------------------------------------

#浏览器传参密文&明文
# from urllib.parse import quote,unquote
# print(quote('参数'))
# print(unquote("%E5%8F%82%E6%95%B0"))
#--------------------------------------------------------

